package tv.accedo.achi.model;

import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.springframework.stereotype.Component;

@Component
@Entity
@Table(name="t_camp")
public class Camp {

	private int id; //generated by native
	private String camp_sn; //unique & not-null
	private String camp_name; // not-null
	private String camp_type; // not-null
	private Date camp_start; // not-null
	private Date camp_end; // not-null
	private int camp_total; // not-null
	private Set<Achi> achis; // many-to-many
	
	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	@Column(unique=true,
			nullable=false)
	public String getCamp_sn() {
		return camp_sn;
	}
	public void setCamp_sn(String camp_sn) {
		this.camp_sn = camp_sn;
	}
	
	@Column(nullable=false)
	public String getCamp_name() {
		return camp_name;
	}
	public void setCamp_name(String camp_name) {
		this.camp_name = camp_name;
	}
	
	@Column(nullable=false)
	public String getCamp_type() {
		return camp_type;
	}
	public void setCamp_type(String camp_type) {
		this.camp_type = camp_type;
	}
	
	@Column(nullable=false)
	public Date getCamp_start() {
		return camp_start;
	}
	public void setCamp_start(Date camp_start) {
		this.camp_start = camp_start;
	}
	
	@Column(nullable=false)
	public Date getCamp_end() {
		return camp_end;
	}
	public void setCamp_end(Date camp_end) {
		this.camp_end = camp_end;
	}
	
	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name="t_camp_achi", 
			joinColumns={@JoinColumn(name="camp_id")},
			inverseJoinColumns={@JoinColumn(name="achi_id")})
	public Set<Achi> getAchis() {
		return achis;
	}
	public void setAchis(Set<Achi> achis) {
		this.achis = achis;
	}
	
	@Column(nullable=false)
	public int getCamp_total() {
		return camp_total;
	}
	public void setCamp_total(int camp_total) {
		this.camp_total = camp_total;
	}
	
	
}
